<template>
    <avue-form ref="fundFormRef" :option="from_option" v-model="form_deposit" @submit="handleSubmit">
    </avue-form>


</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
import { ElMessageBox, ElMessage } from "element-plus";
import {
    getGameCtl,
    setGameCtl
} from "@/apis/admin";
const from_option = ref({
    labelWidth: 120,
    column: [
        {
            label: "杀阶段最小倍率",
            prop: "sysMinRate",
            span: 24,
            labelWidth: 150,
            type: "number",
            labelTip:'杀阶段需要强制让玩家输掉的当前携带金额的百分比',
            rules: [
                {
                    required: true,
                    message: "杀阶段最小倍率",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "杀阶段最大倍率",
            prop: "sysMaxRate",
            labelTip:'暂无',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "杀阶段最大倍率",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "新手补偿次数",
            prop: "newHandGameTimes1",
            span: 24,
            labelWidth: 160,
            labelTip:'新手账户前多少次游戏走新手库存配置',
            type: "number",
            rules: [
                {
                    required: true,
                    message: "新手补偿次数",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "新手补偿完后杀比例",
            prop: "newGiveKillRate",
            span: 24,
            labelWidth: 160,
            labelTip:'新手补偿完后，杀玩家得到的补偿比例。例如0-100',
            type: "number",
            rules: [
                {
                    required: true,
                    message: "新手补偿次数",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "新手游戏次数(2)",
            prop: "newHandGameTimes2",
            labelTip:'新手账号前多少把游戏会触发新手补偿',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "新手游戏次数(2)",
                    trigger: "blur",
                },
            ],
        },

        {
            label: "触发大奖剩余比例",
            prop: "newHandRemainRate",
            labelTip:'触发新手补偿时账户余额需要达到最近一次充值金额的多少百分比',
            labelWidth: 160,
            span: 24,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "触发大奖剩余比例",
                    trigger: "blur",
                },
            ],
        },
        
        {
            label: "触发大奖剩余比例1",
            prop: "newHandRemainRate2",
            labelTip:'触发新手补偿时账户余额需要达到最近一次充值金额的多少百分比',
            labelWidth: 160,
            span: 24,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "触发大奖剩余比例",
                    trigger: "blur",
                },
            ],
        },
        
        {
            label: "触发大奖剩余比例2",
            prop: "newHandRemainRate3",
            labelTip:'触发新手补偿时账户余额需要达到最近一次充值金额的多少百分比',
            labelWidth: 160,
            span: 24,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "触发大奖剩余比例",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "大奖奖励最小倍数",
            prop: "newHandRewardMinRate",
            span: 24,
            labelWidth: 160,
            labelTip:'补偿奖励最低为下注金额的多少倍',
            type: "number",
            rules: [
                {
                    required: true,
                    message: "大奖奖励最小倍数",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "大奖奖励最大倍数",
            prop: "newHandRewardMaxRate",
            span: 24,
            labelWidth: 160,
            labelTip:'补偿奖励最高为下注金额的多少倍',
            type: "number",
            rules: [
                {
                    required: true,
                    message: "大奖奖励最大倍数",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "大奖>充值金额倍率",
            prop: "newHandMaxRewardRate",
            span: 24,
            labelTip:'补偿奖励最高不得超过最近一次充值金额的多少倍',
            labelWidth: 180,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "大奖大于充值金额倍率",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "大奖>充值金额倍率2",
            prop: "newHandMaxRewardRate2",
            span: 24,
            labelTip:'补偿奖励最高不得超过最近一次充值金额的多少倍',
            labelWidth: 180,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "大奖大于充值金额倍率",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "大奖>充值金额倍率3",
            prop: "newHandMaxRewardRate3",
            span: 24,
            labelTip:'补偿奖励最高不得超过最近一次充值金额的多少倍',
            labelWidth: 180,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "大奖大于充值金额倍率",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "触发新手的充值上限",
            prop: "newHandMaxRecharge",
            labelTip:'新账号充值多少以下视为新手账号',
            labelWidth: 180,
            span: 24,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "触发新手的充值上限",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "充值倍率控制",
            prop: "rechargeRate",
            labelTip:'单次获利不得高于最近一次充值金额的多少倍，账户携带金币为最近充值金额的多少倍时进入杀阶段',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "充值倍率控制",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "触发大奖几率1",
            prop: "bigWinRate1",
            labelTip:'单次获利不得高于最近一次充值金额的多少倍，账户携带金币为最近充值金额的多少倍时进入杀阶段',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "充值倍率控制",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "触发大奖几率2",
            prop: "bigWinRate2",
            labelTip:'单次获利不得高于最近一次充值金额的多少倍，账户携带金币为最近充值金额的多少倍时进入杀阶段',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "充值倍率控制",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "触发大奖几率3",
            prop: "bigWinRate3",
            labelTip:'单次获利不得高于最近一次充值金额的多少倍，账户携带金币为最近充值金额的多少倍时进入杀阶段',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "充值倍率控制",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "新手赠送最大金额",
            prop: "newHandMaxWin",
            labelTip:'新手补偿奖励最高赠送金额',
            span: 24,
            labelWidth: 160,
            type: "number",
            rules: [
                {
                    required: true,
                    message: "新手赠送最大金额",
                    trigger: "blur",
                },
            ],
        },
        {
            label: "新手库存开关",
            prop: "newHandStockDay",
            labelTip:'新手库存开关,不开的就传0天',
            span: 12,
            type: "switch",
        },
        {
            label: "是否开启",
            prop: "isOpen",
            span: 12,
            type: "switch",
        },
    ],
});
const form_deposit = ref({});
const handleSubmit = (form, done) => {
    console.log('from', form)
    setGameCtl
        .post("", {
            ...form,
            sysMinRate: form.sysMinRate * 10000,
            sysMaxRate: form.sysMaxRate * 10000,
            newHandRemainRate: form.newHandRemainRate * 10000,
            newHandRemainRate2: form.newHandRemainRate2 * 10000,
            newHandRemainRate3: form.newHandRemainRate3 * 10000,
            bigWinRate1:form.bigWinRate1 * 10000,
            bigWinRate2:form.bigWinRate2 * 10000,
            bigWinRate3:form.bigWinRate3 * 10000,
            newHandRewardMinRate: form.newHandRewardMinRate * 10000,
            newHandRewardMaxRate: form.newHandRewardMaxRate * 10000,
            newHandMaxRewardRate: form.newHandMaxRewardRate * 10000,
            newHandMaxRewardRate2: form.newHandMaxRewardRate2 * 10000,
            newHandMaxRewardRate3: form.newHandMaxRewardRate3 * 10000,
            newHandMaxRecharge:form.newHandMaxRecharge * 100,
            rechargeRate:form.rechargeRate * 10000,
            isOpen: form.isOpen ? 1 : 0,
            newHandMaxWin:form.newHandMaxWin * 100,
            newHandStockDay:form.newHandStockDay?1:0
        })
        .then((res) => {
            done();
            if (res.code == 200) {
                ElMessage.success("修改已保存");
                gameList();
            }
        });
};
const gameList = async () => {

    let _data = await async_getGameStock();
    console.log('游戏配置', _data)
    _data.sysMinRate = _data.sysMinRate / 10000;
    _data.sysMaxRate = _data.sysMaxRate / 10000;
    _data.newHandRemainRate = _data.newHandRemainRate / 10000;
    _data.newHandRemainRate2 = (_data.newHandRemainRate2 || 0) / 10000;
    _data.newHandRemainRate3 = (_data.newHandRemainRate3 || 0) / 10000;
    _data.bigWinRate1 = _data.bigWinRate1 / 10000;
    _data.bigWinRate2 = _data.bigWinRate2 / 10000;
    _data.bigWinRate3 = _data.bigWinRate3 / 10000;
    _data.newHandRewardMinRate = _data.newHandRewardMinRate / 10000;
    _data.newHandRewardMaxRate = _data.newHandRewardMaxRate / 10000;
    _data.newHandMaxRewardRate = _data.newHandMaxRewardRate / 10000;
    _data.newHandMaxRewardRate2 = (_data.newHandMaxRewardRate2 || 0) / 10000;
    _data.newHandMaxRewardRate3 = (_data.newHandMaxRewardRate3 || 0) / 10000;
    _data.newHandMaxRecharge = _data.newHandMaxRecharge / 100;
    _data.rechargeRate = _data.rechargeRate / 10000;
    _data.isOpen=_data.isOpen?true:false
    _data.newHandMaxWin = _data.newHandMaxWin / 100
    _data.newHandStockDay = _data.newHandStockDay?true:false
    form_deposit.value = _data;
}
const async_getGameStock = async () => {
    let data = await getGameCtl.post("", {})
    return data.data
}
onMounted(() => {
    // getList();
    gameList()
});
</script>